  <?php
 	
class Login extends CI_Controller {

  public function __construct()
      {
          parent::__construct();
          $this->load->model('userinfo_model');
          $this->load->helper('url_helper');
      }

      public function login()
      {
       
        $data['title'] = "login"; // Capitalize the first letter

        $this->load->view('templates/header', $data);
        $this->load->view('jhdy/login', $data);
        $this->load->view('templates/footer', $data);
      }
  

      public function index()
      {
          $data['userinfos'] = $this->userinfo_model->getUsers();
          $data['title'] = 'All Users';

        $this->load->view('templates/header', $data);
        $this->load->view('jhdy/login', $data);
        $this->load->view('templates/footer');   
    }

    public function create()
  {
    $this->load->helper('form');
    $this->load->library('form_validation');

    $data['title'] = 'Create a user';

    $this->form_validation->set_rules('name', '用户名', 'required');
    $this->form_validation->set_rules('password', '密码', 'required');
  
    if ($this->form_validation->run() === FALSE)
    {
        $this->load->view('templates/header', $data);
        $this->load->view('jhdy/useradd');
        $this->load->view('templates/footer');

    }
    else
    {
        $this->userinfo_model->add();
        $this->load->view('jhdy/success');
    }
}

  }
